﻿

function changeComplexProvince(provincecode) {
		$("#seachcity").empty(); //改变省份时先清空原先的市
		$("#seachdistrict").empty();
		var seachcity = $("#seachcity");
		var province = $("#seachprov option:selected").text();
		$("#province").val(province);
		var editUrl ="/HRTWeb3/HRTWEB/address/city/list.do?";
		$.ajax({

			url : editUrl,
			dataType : 'json',
			cache : false,
			data : {
				provincecode : provincecode
			},
			success : function(data) {
				var results = data.cityList;
				
				var rowContent = "<option  value ='-1' >请选择</option>";
				if(results!=null){
					
					for(i=0;i<results.length;i++){
						var city =results[i];
						rowContent = rowContent+"<option  value ="+city.code+" >"+city.name+"</option>";
					}
				}
				seachcity.append(rowContent);
			},
			error : function(html) {
				alert("Load Data failly");
				refresh();
			}
		});
	
  
}

 
function changeCity(citycode) {
	$("#seachdistrict").empty(); //改变城市时先删除原先的区
	var seachdistrict = $("#seachdistrict");
	
	var city = $("#seachcity option:selected").text();
	$("#city").val(city);
	
	var editUrl ="/HRTWeb3/HRTWEB/address/area/list.do?";
	$.ajax({

		url : editUrl,
		dataType : 'json',
		cache : false,
		data : {
			citycode : citycode
		},
		success : function(data) {
			var results = data.areaList;
			
			var rowContent = "<option  value ='-1' >请选择</option>";
			if(results!=null){
				
				for(i=0;i<results.length;i++){
					var area =results[i];
					rowContent = rowContent+"<option  value ="+area.code+" >"+area.name+"</option>";
				}
			}
			seachdistrict.append(rowContent);
		},
		error : function(html) {
			alert("Load Data failly");
			refresh();
		}
	});
    
}
function changeArea(areacode){
	var area = $("#seachdistrict option:selected").text();
	$("#area").val(area);
}

function clearAddress() {
	$("#seachprov").empty(); 
	$("#seachcity").empty(); 
	$("#seachdistrict").empty(); 
}
